/**
 * 封装ajax
 * 
 * @param ajaxInfo
 */
function LocalAjax(ajaxInfo) {
	// 默认参数设置
	var defaultInfo = {
		type : "POST",
		dataType : "json",
		contentType : 'application/json; charset=UTF-8',
		async: true,
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			printMsg(errorThrown, textStatus);
			if("error" == textStatus){
	    		if(XMLHttpRequest && XMLHttpRequest.responseJSON && "SessionTimeoutException" == XMLHttpRequest.responseJSON.message){
	    			//icon的值有-1到6
	    			//-1：无图标 0：叹号 1：打勾 2：错误X 3：问号 4：锁 5：哭脸 6：笑脸
	    			layer.alert('登陆过期，请重新登录',{icon: 0},function(){
	    				window.location.href = contextPath;
	    			});
	    		}
	    	} else {
	    		layer.alert('系统出现未知错误，请刷新页面',{icon: 5});
	    		return false;
	    	}
		},
		success : function(data, textStatus, jqXHR) {
			printMsg("ajax调用成功，" + data, textStatus);
		}
	};

	// 补全参数
	if (typeof ajaxInfo.type == "undefined") {
		ajaxInfo.type = defaultInfo.type;
	}
	if (typeof ajaxInfo.dataType == "undefined") {
		ajaxInfo.dataType = defaultInfo.dataType;
	}
	if (typeof ajaxInfo.contentType == "undefined") {
		ajaxInfo.contentType = defaultInfo.contentType;
	}
	if (typeof ajaxInfo.async == "undefined") {
		ajaxInfo.async = defaultInfo.async;
	}
	if (typeof ajaxInfo.error == "undefined") {
		ajaxInfo.error = defaultInfo.error;
	}
	if (typeof ajaxInfo.success == "undefined") {
		ajaxInfo.success = defaultInfo.success;
	}

	// 调用ajax
	$.ajax(ajaxInfo);
}

/**
 * 控制台打印信息
 * 
 * @param msg
 * @param type
 */
function printMsg(msg, type) {
	try {
		if ("error" == type) {
			console.error("error: " + msg);
		} else {
			console.warn(type + " " + msg);
		}
	} catch (ex) {
	}
}